fix(nuxt): reach app tsconfig with server auto-import types#437
Conversation
types/evlog-server.d.ts was only registered on the nitro tsconfig context, so `useLogger`/`log`/`createEvlogError` resolved to TS2304 in the app tsconfig project. $fetch's return-type inference imports server route modules directly, pulling their auto-imports into the app project's typecheck too. Register the template on the nuxt context as well. Fixes #435
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
Thank you for following the naming conventions! 🙏 |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: ASSERTIVE Plan: Pro Plus Run ID: 📒 Files selected for processing (3)
📝 WalkthroughWalkthroughThe Nuxt module now registers ChangesNuxt typecheck fix
Estimated code review effort: 2 (Simple) | ~10 minutes Possibly related PRs
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Warning There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure. 🔧 ESLint
ESLint install timed out. The project may have too many dependencies for the sandbox. Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
commit: |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@packages/evlog/src/nuxt/module.ts`:
- Around line 494-499: Update the Nuxt type reference configuration in the
visible module setup to keep types/evlog-server.d.ts Nitro-only by removing its
nuxt: true inclusion, while preserving the existing nitro: true registration.
Ensure the app project continues to receive only types/evlog-client.d.ts so
global log and createEvlogError declarations are not duplicated.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: ASSERTIVE
Plan: Pro Plus
Run ID: e2d6f157-111c-4923-a3d6-3e07099a3d18
📒 Files selected for processing (3)
.changeset/fix-nuxt-typecheck-server-globals.mdpackages/evlog/src/nuxt/module.tspackages/evlog/test/nuxt/module-type-templates.test.ts
Address CodeRabbit feedback on #437: declaring the server template's `log` global on the nuxt context too collided with the client `log` already declared in evlog-client.d.ts. Nuxt's generated tsconfigs set skipLibCheck: true, so TypeScript silently kept whichever declaration it saw first instead of erroring. Split the server type template: useLogger/createEvlogError stay on both nitro+nuxt contexts (identical types, no collision), while log moves to its own nitro-only template.
Closes #435
Problem
Since 2.21.0,
nuxt typecheckfails withTS2304: Cannot find name 'useLogger'(andlog/createEvlogError) on server routes.The
types/evlog-server.d.tstype template was only registered on thenitrotsconfig context. That reaches.nuxt/tsconfig.server.json, but$fetch's return-type inference doestypeof import('../../server/api/...'), which imports the server route modules directly and pulls their auto-imports into the app tsconfig project's typecheck as well — and that project never referenced the template.Fix
Register the template on both the
nitroandnuxtcontexts ofaddTypeTemplate, so the reference also flows intonuxt.d.ts(included bytsconfig.app.json).Verification
apps/playground:vue-tsc -p .nuxt/tsconfig.app.jsonfailed with ~18TS2304errors before the fix, none after.packages/evlog/test/nuxt/module-type-templates.test.ts) asserting the type template is registered with{ nitro: true, nuxt: true }— verified it fails without the fix and passes with it.pnpm run test,pnpm run lint,pnpm run typecheckall pass across the monorepo (includingevlog-playground:typecheck, which exercises this exact scenario).Summary by CodeRabbit
typecheckfailures on server routes caused by missing logging globals (e.g.,useLogger/createEvlogError) in inferred route types.logscoped to the server project.typecheck.